<?php
defined('_JEXEC') or die('Restricted access');

$jversion = new JVersion();
$j15 = ($jversion->RELEASE == '1.5');
//$j16 = ($jversion->RELEASE == '1.6');

$editor =& JFactory::getEditor();
?>
<style type="text/css">
<!--

table.stexts td.stkey {
  color: #666;
  font-weight: bold;
  border-bottom: 1px solid #D5D5D5;
  border-right: 1px solid #D5D5D5;
  background-color: #f9f9f9;
}

-->
</style>
<script type="text/javascript"><!--

  <?php if ($j15 == true) { ?>
  function submitbutton(task) {
  <?php } else { ?>
  Joomla.submitbutton = function(task) {
  <?php } ?>

    var form = document.adminForm;

    if (task == 'tcancel') {
      <?php if ($j15 != true) { ?>Joomla.<?php } ?>submitform( task );
      return;
    }

   // do field validation
   var text = <?php echo $editor->getContent( 'tcode' ); ?>
   if (text == ""){
     alert( "<?php echo JText::_( 'Template Code cannot be blank', true ); ?>" );
   }
   else {
     <?php
       echo $editor->save( 'tcode' );
     ?>
     <?php if ($j15 != true) { ?>Joomla.<?php } ?>submitform( task );
   }
 }

function jInsertEditorText(text, editor) {

  if (editor == 'thumbpath') {
    var first = text.substr(10);
    var s = first.substr(0, first.indexOf('" alt'));
    document.getElementById('thumbpath').value = '<?php
      $juribase = &JURI::base();
      $bas = str_replace('/administrator/', '/', $juribase);
      print $bas;
    ?>' + s;
  }
  else {
    tinyMCE.execInstanceCommand(editor, 'mceInsertContent', false, text);
  }

}

// --></script>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<div class="col width-10 <?php if ($j15 != true) { echo 'fltlft'; } ?>">
    <fieldset class="adminform">
        <legend><?php echo JText::_( 'Details' ); ?></legend>

        <table class="admintable <?php if ($j15 != true) { echo 'adminform'; } ?>">
        <tr>
            <td width="100" align="right" class="key">
                <label for="tname">
                    <?php echo JText::_( 'Template Name' ); ?>:
                </label>
            </td>
            <td>
                <input class="inputbox" type="text" name="tname" id="tname" size="70" maxlength="50"
                value="<?php echo $this->mtmpl->tname;?>" />
            </td>
        </tr>
        <tr>
            <td width="100" align="right" class="key">
                <label for="thumbpath">
                    <?php echo JText::_( 'Template Thumbnail' ); ?>:
                </label>
            </td>
            <td>
                <input class="inputbox" type="text" name="thumbpath" id="thumbpath" size="70" maxlength="50"
                value="<?php
                  $juribase = &JURI::base();
                  $bas = str_replace('/administrator/', '/', $juribase);
                  if (!($this->isNew)) {
                    print $this->mtmpl->thumbpath;
                  }
                  else {
                    print $bas . 'images/';
                  }
                ?>" />&nbsp;
<div class="image">
<a class="modal-button" title="Browse Image"
href="<?php print $juribase; ?>index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;e_name=thumbpath"
onclick="IeCursorFix(); return false;" id="getImage" rel="{handler: 'iframe', size: {x: 570, y: 400}}">Browse Image</a>
</div>
            </td>
        </tr>
        <tr>
            <td width="120" class="key">
                <?php echo JText::_( 'Template HTML Code' ); ?>:
            </td>
            <td>
              <!-- NEWSLETTER SMART TEXT HELP -->
              <a id="toggle" href="#">Toggle Newsletter Smart Text Help</a><br/>
              <div id="smarttexts" style="background-color: #fff; border: 1px solid #D5D5D5; padding: 10px;">
							<table class="stexts">
							<tr><td colspan="2"><strong>Subscriber Smart Text</strong></td><td colspan="2"><strong>URL Smart Text</strong></td></tr>
							<tr><td class="stkey">Subscriber Name: </td><td>{subscriber_name}</td><td class="stkey">One-Click Unsubscribe URL: </td><td>{url:UNSUB}</td></tr>
							<tr><td class="stkey">Subscriber First Name: </td><td>{subscriber_first_name}</td><td class="stkey">Forward to Friend URL: </td><td>{url:FTF}</td></tr>
							<tr><td class="stkey">Subscriber Last Name: </td><td>{subscriber_last_name}</td><td class="stkey">Edit List URL: </td><td>{url:EDITLISTS}</td></tr>
							<tr><td class="stkey">Subscriber Email: </td><td>{subscriber_email}</td><td class="stkey">View Newsletter URL: </td><td>{url:NEWSLETTER}</td></tr>
							<tr><td colspan="2"><strong>Email Open Tracking Image</strong></td><td colspan="2"><strong>Link Smart Text</strong></td></tr>
							<tr><td class="stkey">White 1x1 Image: </td><td>{img:white}</td><td class="stkey">One-Click Unsubscribe Link: </td><td>{link:UNSUB}Your Text here{/link}</td></tr>
							<tr><td class="stkey">Black 1x1 Image: </td><td>{img:black}</td><td class="stkey">Forward to Friend Link: </td><td>{link:FTF}Your Text here{/link}</td></tr>
							<tr><td class="stkey">Red 1x1 Image: </td><td>{img:red}</td><td class="stkey">Edit List Link: </td><td>{link:EDITLISTS}Your Text here{/link}</td></tr>
							<tr><td class="stkey">Green 1x1 Image: </td><td>{img:green}</td><td class="stkey">View Newsletter Link: </td><td>{link:NEWSLETTER}Your Text here{/link}</td></tr>
							<tr><td class="stkey">Blue 1x1 Image: </td><td>{img:blue}</td><td></td><td></td></tr>
							<tr><td colspan="2"><strong>Includes</strong></td><td colspan="2"><strong>Special Smart Text</strong></td></tr>
							<tr><td class="stkey">Joomla! Article: </td><td>{include:article}article_id{/include}</td><td class="stkey">Random Content Display:</td><td>{random:50%}Your Content{/random}</td></tr>
							<tr><td class="stkey">Joomla! Article Title: </td><td>{include:articletitle}article_id{/include}</td><td></td><td></td></tr>
							<tr><td class="stkey">Joomla! Article Intro: </td><td>{include:articleintro}article_id{/include}</td><td></td><td></td></tr>
							<tr><td class="stkey">Joomla! Module: </td><td>{include:module}module_id{/include}</td><td></td><td></td></tr>
							<tr><td class="stkey">Joomla! Module Position: </td><td>{include:moduleposition}position_name{/include}</td><td></td><td></td></tr>
							<tr><td class="stkey">Extra Field Value: </td><td>{include:field}field_id{/include}</td><td></td><td></td></tr>
							</table>
              </div>
              <br/>
            <script type="text/javascript">
            <!--

              var mySlide = new Fx.Slide('smarttexts');

              $('toggle').addEvent('click', function(e){
                e = new Event(e);
                mySlide.toggle();
                e.stop();
              });

              mySlide.toggle();

            //-->
            </script>
              <?php
                 echo $editor->display('tcode', $this->mtmpl->tcode, '728', '400', '180', '20');
              ?>
            </td>
        </tr>
        <tr>
            <td width="110" class="key">
                <label for="notes">
                    <?php echo JText::_( 'Notes' ); ?>:
                </label>
            </td>
            <td>
                <textarea class="textarea" name="notes" id="notes" cols="42" rows="8"><?php echo $this->mtmpl->notes; ?></textarea>
            </td>
        </tr>
        </table>
    </fieldset>
</div>
<div class="clr"></div>

<input type="hidden" name="option" value="com_nspro" />
<input type="hidden" name="id" value="<?php echo $this->mtmpl->id; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="nspro" />
</form>

<small><i>NS Pro by <a href="http://www.mavrosxristoforos.com/">Mavrosxristoforos.com</a> Copyright 2009-2011</i></small>